package com.kot.matchingsystem.service.impl;

import com.kot.matchingsystem.service.MatchingService;
import com.kot.matchingsystem.service.impl.utils.MatchingPool;
import org.springframework.stereotype.Service;

@Service
public class MatchingServiceImpl implements MatchingService {
    public final static MatchingPool matchingPool = new MatchingPool();//匹配全程只有一个多线程，所以可以开成静态变量
    @Override
    public String addPlayer(Integer userId, Integer rating) {
//        //System.out.println("add player: " + userId + " " + rating);
        matchingPool.addPlayer(userId, rating);//接受另一个springboot传来的玩家参数，并加入匹配队列
        return "add player success";
    }

    @Override
    public String removePlayer(Integer userId) {
        //System.out.println("remove player: " + userId);
        matchingPool.removePlayer(userId);//接受另一个springboot传来的玩家参数，并从匹配队列中删除
        return "remove player success";
    }

}
